home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / strlibs.zip / INDEX.C < prev    next >
Text File  |  1993-01-04  |  410b  |  23 lines

  1. #include <stdio.h>
  2.  
  3. int index(s, c)
  4.     register char *s;
  5.     register char c;
  6.     {
  7.         int idx = 0;
  8.         int len = 0;
  9.  
  10.         while (*(s + len++) != '\0');
  11.  
  12.         while ( (*s++ != c) && (idx < len) )
  13.            ++idx;
  14.  
  15.         return idx == len ? -1 : idx;
  16.  
  17. /*      while ((*s++ != c) && *s )
  18.            idx++;
  19.         return *s == 0 ? (c == '\0'? idx : -1) : idx;
  20. */
  21.     }
  22.  
  23.